package com.eight.cloud.payment.controller;


import com.eight.cloud.core.global.result.Result;
import com.eight.cloud.payment.entity.MerchantEntity;
import com.eight.cloud.payment.model.dto.MerchantDto;
import com.eight.cloud.payment.service.IMerchantService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 子商户管理
 *
 * @ClassName: MerchantController
 * @Author: TXC
 * @Date: 2024-10-22 17:18
 **/
@RestController
@RequestMapping("/merchant")
public class MerchantController {
    @Resource
    private IMerchantService merchantService;

    /**
     * 新增商户或者修改商户
     * @param merchant 商户信息
     * @return @Link Result
     */
    @PostMapping("/saveAndUpdate")
    public Result<MerchantEntity> saveAndUpdate(MerchantDto merchant) {
        return Result.ok(merchantService.saveAndUpdate(merchant));
    }

    /**
     * 删除商户
     * @param id 商户id
     * @return @Link Result
     */
    @DeleteMapping("/delete")
    public Result<Boolean> delete(String id) {
        return Result.ok(merchantService.removeById(id));
    }

    /**
     * 查询商户列表
     * @return @Link Result
     */
    @GetMapping("/list")
    public Result<List<MerchantEntity>> list() {
        return Result.ok(merchantService.list());
    }

    /**
     * 获取商户详情
     * @param id 商户id
     * @return @Link Result
     */
    @GetMapping("/get")
    public Result<MerchantEntity> get(String id) {
        return Result.ok(merchantService.getByUuid(id));
    }


}
